<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<c:import url="/head.jsp"></c:import>
<script src="<c:url value='/scripts/jquery-latest.pack.js'/> " type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/scripts/submitcheck.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery-latest.pack.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery.form.js"></script>
<script type="text/javascript">
function show(userID){
	var url = '<%=request.getContextPath()%>/admin/showUser?userID=' + userID;
	window.open(url, '');
}

function modify(userID){
	
	var url = '<%=request.getContextPath()%>/admin/modifyUser?userID=' + userID;
	window.open(url, '');
	
}

function del(){
	 var str="";
	// 得到所有选中的用户账号	
	 $("[name='user'][checked]").each(function(){
	              str+=$(this).val()+"\n";
	         });	

	 var options={type:"POST", 
				url:"<%=request.getContextPath()%>/admin/delUser", 
				dataType:"json",
				data: {'userID':str},
				success:feedback};
		$.ajax(options);
}
function feedback(data){
	if(data.result == 0){
		location.href = '<%=request.getContextPath()%>/admin/userList';
	}else{
		alert('操作失败');
	}
		
}

function newWindow(url){
	window.open(url, '');
}

function search(){
	var userAccount = $("#userAccount").val();
	var userName = $("#userName").val();
	var orgName = $("#orgName").val();
	var userType = $("#userType").val(); 

	var options={type:"POST", 
			url:"<%=request.getContextPath()%>/admin/searchUser", 
			dataType:"json",
			data: {'userAccount':userAccount, 'userName':userName, 
				   'orgName':orgName, 'userType':userType}
			};
	$.ajax(options);
}

function showProList(userType){
	var userID =  $('[name="user"][checked=true]:radio').val();  
	var str = 'userID=' + userID + '&userType=' + userType;
	location.href = '<%=request.getContextPath()%>/admin/showProList?' + str;
}

</script>
<body leftmargin="0" rightmargin="0" topmargin="0">
 
	<table class="tdata">
	<tr>
 		
		<td colspan="6">
			<form method="post" action="<c:url value="/admin/searchUser"/>">
			&nbsp;&nbsp;
			<label>用户账号:</label><input type="text" value="" size="15" id="userAccount" name="userAccount"/>
			&nbsp;&nbsp;
			<label>用户名:</label><input type="text" value="" size="15" id="userName" name="userName"/><br><br>
			<label>组织机构名:</label><input type="text" value="" size="15" id="orgName" name="orgName"/>
			<label>用户类型:</label><input type="text" value="" size="15" id="userType" name="userType"/>
			<input value="搜索" class="btn40" style="margin: 0 0 0 5px;" type="submit"/> 
			
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
			<input value="新增" class="btn40" style="margin: 0 0 0 5px;" type="button" onclick="newWindow('<%=request.getContextPath()%>/views/admin/addUser.jsp')"/> &nbsp;&nbsp;
			<input value="项目" class="btn40" style="margin: 0 0 0 5px;" type="button" onclick="showProList(0)"/> 
			<%-- 
			<input value="删除" class="btn40" style="margin: 0 0 0 5px;" type="button" onclick="del();"/> 
			--%>
			</form>
		</td>
		
	</tr>

	<tr class="tr01" >
		<td align="center" width="5%"><strong>选择</strong></td>
    	<td align="center" width="5%"><strong>序号</strong></td>
		<td align="center" width="25%"><strong>用户账号</strong></td>
		<td align="center" width="15%"><strong>密码</strong></td>
		<td align="center" width="30%"><strong>组织机构名称</strong></td>
		<td align="center" width="8%"><strong>操作</strong></td>
 	 </tr>
   <tbody>
		<c:forEach items="${users}" var="user"  varStatus="status">
			<tr onMouseMove="this.style.backgroundColor='#F1F1F1';"
				onmouseout="this.style.backgroundColor='';">
				<td align="center" style="height: 50px"><input type="radio" name="user" value ="${user.userID}" /></td>
				<td align="center">${startPosi-status.index}&nbsp;</td>
				<td align="center" class="hiddentd" nowrap><c:out value="${user.userAccount}" />&nbsp;</td>
				<td align="center"><c:out value="${user.userPassword}" />&nbsp;</td>
				<td class="hiddentd" style="word-break:break-all;width:350px" nowrap><c:out value="${user.orgName}" />&nbsp;</td>
				
				
				<td align="center" style="word-break:break-all;width:100px">
					<a href="#" onclick="modify('${user.userID}')">修改</a>
					<a href="#" onclick="show('${user.userID}')">显示</a>
				
				</td>
			</tr>
		</c:forEach>
	</tbody>
</table>
${page}
</body>
</html>